<?php

namespace app\common\validate;

use think\Validate;

/**
 * 小程序-登录相关校验
 * Class Calendar
 * @package app\common\validate\mini
 */
class Calendar extends Validate
{
    protected $field = [
        'mini_type' => '小程序类型',
        'code' => '登录时获取的code',
        'encrypted_data' => '加密data',
        'iv' => '加密算法的初始向量iv',
//        'avatar' => '头像图片地址',//下面的都是支付宝小程序需要用到的
//        'nickname' => '昵称',
        'sex' => '性别',
        'city' => '所在市区',
        'province' => '省份',
        'country' => '国家码',
        'tt_raw_data' => 'tt元数据',//下面都是字节跳动小程序需要用到的
        'tt_signature' => 'tt签名',
        'third_id' => 'third_id',
        'token' => 'token'
    ];

    protected $rule = [
        'mini_type' => 'require|in:SWAN,WEAPP,QQ,ALIPAY,TT,H5',
        'code' => 'require',
        'encrypted_data' => 'require',
        'iv' => 'require',
//        'avatar' => 'require',
//        'nickname' => 'require',
        'sex' => 'require|integer|in:1,2',//性别：1：男；2：女；
        'city' => 'require|max:45',
        'province' => 'require|max:45',
        'country' => 'require|max:45',
        'tt_raw_data' => 'require',
        'tt_signature' => 'require',
        'third_id' => 'require',
        'token' => 'require',
    ];

    protected $scene = [
        'alipay' => ['mini_type', 'code', 'sex', 'city', 'province', 'country'],
        'tt' => ['mini_type', 'code', 'encrypted_data', 'iv', 'tt_raw_data', 'tt_signature'],
        'others' => ['mini_type', 'code', 'encrypted_data', 'iv'],
        'calendar_sign' => ['mini_type', 'third_id', 'token']
    ];

}
